package org.ethereum.net.stats;

import java.util.List;

import org.json.simple.JSONObject;

public class ListStats implements SingleKPI {

	private final String kpiName;
	
	private final List<?> queue;
	
	public ListStats(String kpiName, List<?> queue) {
		this.kpiName = kpiName;
		this.queue = queue;
	}
	
	@Override
	public String getKpiName() {
		return kpiName;
	}

	@Override
	public void reset() {
		
	}
	
	public int getQueueSize() {
		return this.queue.size();
	}
	
	public String toString() {
        return toJson().toString();
    }
	
	public JSONObject toJson() {
		JSONObject json = new JSONObject();
		try {
			json.put("KPIName", this.getKpiName());
			json.put("ListSize", this.queue.size());
			json.put("ListType", this.queue.getClass().getSimpleName());
		} catch (Exception e) {
		}
		return json;
	}
}
